<template>
    <a-input disabled :value="holdVal" style="width: 200px" :placeholder="holdVal" />
</template>
<script setup>
import useUserStore from '@/store/modules/user'
const userStore = useUserStore()
import { queryOne } from '@/module/system/api/user'
import Validator from '@/utils/Validator'
import { onUnmounted } from 'vue';
const holdVal = ref('查询中...')
const emit = defineEmits(['update:userId', 'update:nickName'])
const props = defineProps({
    userId: {
        type: [String, Number]
    },
    nickName: {
        type: String
    }
})
function getUser() {
    let userId = userStore.userId;
    //TODO DELETE TODO
    if (userId == 10086) {
        userId = 2
    }

    queryOne(userId).then(res => {
        //console.log(res)
        holdVal.value = `${res.nickName}(${res.userName})`
        emit('update:nickName', res.nickName)
        emit('update:userId', 10086)
    })
}
// 取消挂载
onUnmounted(() => {
    //console.log('取消组件挂载')
    emit('update:nickName', '')
    emit('update:userId', 0)
})
getUser()
</script>